﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;

namespace EventWindowHandler.Plugin
{
    /// <summary>
    /// Interaction logic for ObjectEventInfoView.xaml
    /// </summary>
    public partial class ObjectEventInfoView : UserControl
    {
        public ObjectEventInfoView()
        {
            InitializeComponent();
        }

        public static readonly DependencyProperty ObjectEventInfoViewModelProperty =
            DependencyProperty.Register("ObjectEventInfoViewModel", typeof(ObjectEventInfoViewModel), typeof(ObjectEventInfoView), new PropertyMetadata(null, OnObjectEventInfoViewModelPropertyChanged));

        public ObjectEventInfoViewModel ObjectEventInfoViewModel
        {
            get { return (ObjectEventInfoViewModel)GetValue(ObjectEventInfoViewModelProperty); }
            set { SetValue(ObjectEventInfoViewModelProperty, value); }
        }

        private static void OnObjectEventInfoViewModelPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ObjectEventInfoView source = d as ObjectEventInfoView;
            source.UpdateObjectEventInfoViewModel(e.NewValue as ObjectEventInfoViewModel, e.OldValue as ObjectEventInfoViewModel);
        }

        public void UpdateObjectEventInfoViewModel(ObjectEventInfoViewModel viewModel, ObjectEventInfoViewModel viewModelOld)
        {
            ObjectEventInfoViewModel = viewModel;
            this.DataContext = ObjectEventInfoViewModel;
        }
    }
}
